package com.example.demo.controller;


import com.example.demo.entity.response.jobPlan.JobPlanDetailResp;
import com.example.demo.entity.response.jobPlan.JobPlanResp;
import com.example.demo.entity.ResponseInfo;
import com.example.demo.service.JobPlanService;
import com.example.demo.utils.PageInfoNew;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/jobPlan")
@Api(tags = "任务报告管理接口")
public class JobPlanController {

    @Resource
    JobPlanService jobPlanService;

    @GetMapping("/page")
    @ApiOperation(value = "任务报告分页接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", required = true, dataType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "每页长度", required = true, dataType = "int"),
            @ApiImplicitParam(name = "projectId", value = "项目id", required = true, dataType = "int")})
    public ResponseInfo<PageInfoNew<JobPlanResp>> page(@RequestParam int pageNum, @RequestParam int pageSize, @RequestParam int projectId) {
        return ResponseInfo.successInfo(jobPlanService.page(pageNum, pageSize, projectId));
    }

    @GetMapping("/details")
    @ApiOperation(value = "任务报告详情")
    @ApiImplicitParam(name = "id", value = "任务报告id", required = true, dataType = "int")
    public ResponseInfo<JobPlanDetailResp> details(@RequestParam int id) {

        return ResponseInfo.successInfo(jobPlanService.details(id));
    }

    @PostMapping("/delete")
    @ApiOperation(value = "任务报告删除")
    @ApiImplicitParam(name = "id", value = "计划id", required = true, dataType = "int")
    public ResponseInfo<String> delete(@RequestParam int id) {
        jobPlanService.delete(id);
        return ResponseInfo.successInfo("");
    }

}
